import json

import cv2
import easydict

from cjc import project_setting
from cjc.tools.cv2_base64 import cv2_image_to_base64


def put_tracker_img_2(queue, img):
    if queue.full():
        pass
    else:
        ed = easydict.EasyDict()
        ed.img = cv2_image_to_base64(img)
        queue.put(ed)


def put_tracker_data_2(queue, img, track_data, video_path=None, force=False):
    if queue is None:
        return
    if queue.full():
        if force:
            queue.get()
        else:
            return
        # print("queue 满了当前数量：", queue.qsize())
    ed = easydict.EasyDict()
    ed.video_path = video_path
    # ed.project_id = project_setting.project_id
    if img is not None:
        ed.img = cv2_image_to_base64(img)
    if track_data is not None:
        ed.track = track_data
    queue.put(ed)
